package cn.lg.soar.cms.biz.modules.article.controller;

import cn.lg.soar.cms.api.constant.ModuleConst;
import cn.lg.soar.cms.biz.modules.article.entity.ArticleCommentLike;
import cn.lg.soar.cms.biz.modules.article.service.ArticleCommentLikeService;
import cn.lg.soar.common.model.HttpResult;
import cn.lg.soar.common.model.PageQuery;
import cn.lg.soar.common.model.PageResult;
import cn.lg.soar.core.annotations.IdempotentByParam;
import cn.lg.soar.core.annotations.constraints.group.Create;
import cn.lg.soar.core.annotations.constraints.group.Update;
import cn.lg.soar.database.base.controller.BaseController;
import cn.lg.soar.database.query.QueryParams;
import cn.lg.soar.mvc.annotations.Log;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List;

/**
 * 文章评论点赞
 * @author luguoxiang
 * @since 2025-02-23
 * 开源项目：https://gitee.com/lgx1992/lg-soar 求star！请给我star！请帮我点个star！
 */
@Api(tags = "文章评论点赞")
@Validated
@RestController
@RequestMapping(ModuleConst.MODULE_NAME + "/article/comment/like")
public class ArticleCommentLikeController extends BaseController<ArticleCommentLike, ArticleCommentLikeService> {

    @Override
    protected Serializable getId(ArticleCommentLike entity) {
        return entity.getCommentId();
    }

    @Log(value = "新增文章评论点赞", data = "#p0", dataId = "#$r.data")
    @IdempotentByParam("#p0")
    @ApiOperation("新增")
    @RequestMapping(path = "create", method = RequestMethod.POST)
    public HttpResult<Serializable> create(@RequestBody @Validated(Create.class) ArticleCommentLike data) {
        return super.createResult(data);
    }

    @Log(value = "修改文章评论点赞", data = "#p0", dataId = "#p0.id")
    @ApiOperation("修改")
    @RequestMapping(path = "update", method = RequestMethod.POST)
    public HttpResult<Void> update(@RequestBody @Validated(Update.class) ArticleCommentLike data) {
        return super.updateResult(data);
    }

    @Log(value = "删除文章评论点赞", data = "#p0")
    @ApiOperation(value = "删除", notes = "根据 id 删除")
    @RequestMapping(path = "remove", method = RequestMethod.POST)
    public HttpResult<Void> remove(@RequestBody List<Long> ids) {
        return super.removeResult(ids);
    }

    @ApiOperation(value = "详情", notes = "根据 ID 获取一条数据")
    @RequestMapping(path = "detail", method = RequestMethod.GET)
    public HttpResult<ArticleCommentLike> detail(@RequestParam Long id) {
        return super.detailResult(id);
    }

    @ApiOperation(value = "查询", notes = "多功能查询（分页、列表、统计）")
    @RequestMapping(path = "query", method = RequestMethod.GET)
    public HttpResult<PageResult<ArticleCommentLike>> query(PageQuery pageQuery, QueryParams params){
        return super.queryResult(pageQuery, params);
    }

    @Log(value = "导出文章评论点赞")
    @ApiOperation("导出")
    @RequestMapping(path = "export", method = RequestMethod.GET)
    public void exports(String filename, QueryParams params, HttpServletResponse resp){
        super.exportExcel(filename, params, resp);
    }

    @Log(value = "导入文章评论点赞")
    @ApiOperation("导入")
    @RequestMapping(path = "import", method = RequestMethod.POST)
    public HttpResult<Void> imports(HttpServletRequest req){
        return super.importExcel(req);
    }

}